const mongoose = require('mongoose')

module.exports = new Promise((resolve, reject) => {
    //连接数据库
    mongoose.set('useCreateIndex', true) //加上这个
    mongoose.connect('mongodb://localhost:27017/wx_movie', { useNewUrlParser: true });
    //绑定事件监听
    mongoose.connection.once('open', err => {
        if (!err) {
            console.log('数据库连接~~成功');
            resolve();
        } else {
            reject('数据库连接失败：' + err);
        }
    })
})